<template>
  <div class="home-card">
    <div class="home-card-inner">
      <div class="user-info">
        <div class="avatar-wrapper">
          <ImageView :src="avatar" round />
        </div>

        <div class="nickname">{{nickname}}</div>
        <div class="shelf-text">书架共有{{data.num}}本好书</div>
        <div class="round-item"></div>
        <div class="shelf-text">特别精选</div>
      </div>
      <div class="book-info">
        <div class="book-wrapper">
          <div class="book-image-wrapper" v-for="(item,index) in bookList" :key="index"
            @click="onBookClick"
          >
            <ImageView
              :src='item.cover'
            />
          </div>

        
        </div>
        <div class="sheif-wrapper">
          <div class="shelf">书架</div>
          <van-icon class="arrow" name="arrow" size="11px" color="#828489"></van-icon>
        </div>
      </div>
      <div class="feedback-wrapper"></div>
      <div class="feedback-text" @click="onFeedBackClick">反馈</div>
      <van-dialog id="van-dialog"></van-dialog>
    </div>
  </div>
</template>

<script>
import ImageView from "../base/ImageView";
import Dialog from 'vant-weapp/dist/dialog/dialog';
export default {
  components: {
    ImageView
  },
  props: {
    data: Object,
    hasSign: {
      type: Boolean,
      default: false
    },
    signDay: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {};
  },
computed: {
  avatar(){
    return (this.data && this.data.userInfo && this.data.userInfo.avatar) || ''
    
  },
  nickname(){
    return (this.data && this.data.userInfo && this.data.userInfo.nickname) || ''
    
  },
   bookList(){
    return this.data && this.data.bookList || []
    
  },
  
},
  methods: {
    //跳转书架
    gotoShelf() {},
    //图书点击
    onBookClick() {
      this.$emit('onClick')

    },
    //签到事件
    sign() {},
    onFeedBackClick() {
        Dialog.confirm({
            title:'反馈',
            message:'您是否确认提价反馈信息？',
            confirmButtonText:'是',
            cancelButtonText:'否'
        }).then(()=>{
            console.log('提交是之后的事件');
            
        }).catch(()=>{
            console.log('提交否之后的事件');
            
        })


    }
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {}
};
</script>
<style lang="scss" scoped>
/* @import url(); 引入css类 */
.home-card {
  background-image: linear-gradient(-90deg, #54575f 0%, #595b60 100%);
  border-radius: 15px;
  margin: 22px 20px 0;
  .home-card-inner {
    position: relative;
    padding: 21.5px 17px 20px 20px;
    box-sizing: border-box;
    .user-info {
      display: flex;
      align-items: center;
      .avatar-wrapper {
        height: 20px;
        width: 20px;
      }
      .nickname {
        font-size: 12px;
        color: #fff;
      }
      .shelf-text {
        opacity: 0.7;
        font-size: 12px;
        color: #fff;
      }
      .round-item {
        width: 4px;
        height: 4px;
        background: #a2a2a2;
        border-radius: 50%;
        margin: 0 8px;
      }
      .nickname {
        margin: 0 8.5px;
      }
    }
    .book-info {
      display: flex;
      margin-top: 16.5px;
      .book-wrapper {
        flex: 1;
        display: flex;
        justify-content: space-around;
        .book-image-wrapper {
          width: 72px;
          height: 101px;
        }
      }
      .sheif-wrapper {
        display: flex;
        align-items: center;
        .shelf {
          font-size: 11px;
          width: 11px;
          word-break: break-word;
          color: #fff;
          opacity: 0.8;
        }
      }
    }
    .feedback-wrapper {
      position: absolute;
      right: 0;
      top: 19.5px;
      border-radius: 100px 0 0 100px;
      width: 44.5px;
      height: 23.5px;
      background: #d8d8d8;
      opacity: 0.3;
    }
    .feedback-text {
      position: absolute;
      right: 0;
      top: 19.5px;
      font-size: 11px;
      color: #fff;
      width: 44.5px;
      height: 23.5px;
      line-height: 23.5px;
      text-align: center;
    }
  }
}
</style>